<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const num = ref<any>('')
const className = ref<any>('')
const confirm = () => {
    if(!num.value){
        className.value = 'err error'
        return
    }
    if (num.value === '13817763538') {
        className.value = 'success'
        localStorage.setItem('phone', num.value)
        className.value = 'success'
        setTimeout(()=>{
            router.push('/home')
        },400)
    } else {
        className.value = 'error'
        return
    }
}
</script>

<template>
    <div class="login">
        <div class="main">
            <input v-model="num" type="password" placeholder="请输入访问验证码">
            <button @click="confirm">确认</button>
            <div :class="className">
                <span v-show="className=='err error'">请输入验证码</span>
                <span v-show="className=='error'">验证码错误</span>
                <span v-show="className=='success'">验证码正确</span>
            </div>
        </div>
    </div>
</template>

<style scoped lang="scss">
.logo {
    height: 6em;
    padding: 1.5em;
    will-change: filter;
    transition: filter 300ms;
}

.logo:hover {
    filter: drop-shadow(0 0 2em #646cffaa);
}

.logo.vue:hover {
    filter: drop-shadow(0 0 2em #42b883aa);
}


.login {
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;

    .main {
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
    }

    input {
        padding: 12px 10px;

        border: 1px solid #828282;
        border-right: none;
        font-size: 18px;
        border-radius: 5px 0 0 5px;
        display: block;
        z-index: 999;
        bottom: 10px;
    }

    .error {
        width: 100px;
        color: red;
        position: absolute;
        z-index: 999;
        top: 50px;
        left: 0;
    }
    .success{
        width: 100px;
        color: green;
        position: absolute;
        z-index: 999;
        top: 50px;
        left: 0;
    }
    button {
        padding: 15px 30px;
        border: none;
        color: white;
        background-color: rgb(80, 80, 220);
        cursor: pointer;
        border-radius: 0 5px 5px 0;
    }
}</style>